//package com.redis.config;
//
//import com.redis.constant.OrderMQConstants;
//import org.springframework.amqp.core.*;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.util.HashMap;
//import java.util.Map;
//
//@Configuration
//public class TopicRabbitConfig {
//
//
//    /**
//     * 订单自动收货声明普通交换机
//     *
//     * @return
//     */
//    @Bean(OrderMQConstants.RECEIVED_ORDER_NORMAL_EXCHANGE)
//    public DirectExchange receivedOrderNormalExchange() {
//        return new DirectExchange(OrderMQConstants.RECEIVED_ORDER_NORMAL_EXCHANGE);
//    }
//
//    /**
//     * 订单自动收货声明死信交换机
//     *
//     * @return
//     */
//    @Bean(OrderMQConstants.RECEIVED_ORDER_EXCHANGE)
//    public DirectExchange receivedDeadExchange() {
//        return new DirectExchange(OrderMQConstants.RECEIVED_ORDER_EXCHANGE);
//    }
//
//    /**
//     * 订单自动收货声明订单死信队列
//     *
//     * @return
//     */
//    @Bean(OrderMQConstants.RECEIVED_ORDER_DEAD_QUEUE)
//    public Queue receivedOrderDeadQueue() {
//        return QueueBuilder.durable(OrderMQConstants.RECEIVED_ORDER_DEAD_QUEUE).build();
//    }
//
//    /**
//     * 订单自动收货绑定私信队列
//     *
//     * @return
//     */
//    @Bean(OrderMQConstants.RECEIVED_ORDER_QUEUE)
//    public Queue receivedOrderQueue() {
//        Map<String, Object> arguments = new HashMap<>();
//        //设置死信交换机
//        arguments.put(OrderMQConstants.DEAD_LETTER_EXCHANGE, OrderMQConstants.RECEIVED_ORDER_EXCHANGE);
//        //设置死信routingKey
//        arguments.put(OrderMQConstants.DEAD_LETTER_ROUTING_KEY, OrderMQConstants.RECEIVED_ORDER_DEAD_ROUTING_KEY);
//        arguments.put(OrderMQConstants.MESSAGE_TTL, OrderMQConstants.RECEIVED_ORDER_TIME);
//
//        return QueueBuilder.durable(OrderMQConstants.RECEIVED_ORDER_QUEUE).withArguments(arguments).build();
//    }
//
//
//    /**
//     * 自动取消订单交换机绑定路由key
//     *
//     * @param cancelOrderQueue
//     * @param cancelOrderExchange
//     * @return
//     */
//    @Bean
//    public Binding receivedOrderBindingNExchange(@Qualifier(OrderMQConstants.RECEIVED_ORDER_QUEUE) Queue cancelOrderQueue,
//                                                 @Qualifier(OrderMQConstants.RECEIVED_ORDER_NORMAL_EXCHANGE) DirectExchange cancelOrderExchange) {
//
//        return BindingBuilder.bind(cancelOrderQueue).to(cancelOrderExchange).with(OrderMQConstants.RECEIVED_ORDER_ROUTING_KEY);
//    }
//
//    /**
//     * 订单自动收货绑定私信路由key
//     *
//     * @param orderDeadQueue
//     * @param orderDeadQueue
//     * @return
//     */
//    @Bean
//    public Binding receivedOrderDeadBindingDExchange(@Qualifier(OrderMQConstants.RECEIVED_ORDER_DEAD_QUEUE) Queue orderDeadQueue,
//                                                     @Qualifier(OrderMQConstants.RECEIVED_ORDER_EXCHANGE) DirectExchange orderDeadExchange) {
//        return BindingBuilder.bind(orderDeadQueue).to(orderDeadExchange).with(OrderMQConstants.RECEIVED_ORDER_DEAD_ROUTING_KEY);
//    }
//
//
//    /**
//     * 取消订单声明普通交换机
//     *
//     * @return
//     */
//    @Bean(OrderMQConstants.CANCEL_ORDER_NORMAL_EXCHANGE)
//    public DirectExchange cancelOrderNormalExchange() {
//        return new DirectExchange(OrderMQConstants.CANCEL_ORDER_NORMAL_EXCHANGE);
//    }
//
//    /**
//     * 取消订单声明死信交换机
//     *
//     * @return
//     */
//    @Bean(OrderMQConstants.CANCEL_ORDER_EXCHANGE)
//    public DirectExchange cancelDeadExchange() {
//        return new DirectExchange(OrderMQConstants.CANCEL_ORDER_EXCHANGE);
//    }
//
//    /**
//     * 取消订单声明订单死信队列
//     *
//     * @return
//     */
//    @Bean(OrderMQConstants.CANCEL_ORDER_DEAD_QUEUE)
//    public Queue cancelOrderDeadQueue() {
//        return QueueBuilder.durable(OrderMQConstants.CANCEL_ORDER_DEAD_QUEUE).build();
//    }
//
//    /**
//     * 取消订单绑定私信队列
//     *
//     * @return
//     */
//    @Bean(OrderMQConstants.CANCEL_ORDER_QUEUE)
//    public Queue cancelOrderQueue() {
//        Map<String, Object> arguments = new HashMap<>();
//        //设置死信交换机
//        arguments.put(OrderMQConstants.DEAD_LETTER_EXCHANGE, OrderMQConstants.CANCEL_ORDER_EXCHANGE);
//        //设置死信routingKey
//        arguments.put(OrderMQConstants.DEAD_LETTER_ROUTING_KEY, OrderMQConstants.CANCEL_ORDER_DEAD_ROUTING_KEY);
//        arguments.put(OrderMQConstants.MESSAGE_TTL, OrderMQConstants.CANCEL_ORDER_TIME);
//
//        return QueueBuilder.durable(OrderMQConstants.CANCEL_ORDER_QUEUE).withArguments(arguments).build();
//    }
//
//
//    /**
//     * 取消订单交换机绑定路由key
//     *
//     * @param cancelOrderQueue
//     * @param cancelOrderExchange
//     * @return
//     */
//    @Bean
//    public Binding cancelOrderBindingNExchange(@Qualifier(OrderMQConstants.CANCEL_ORDER_QUEUE) Queue cancelOrderQueue,
//                                               @Qualifier(OrderMQConstants.CANCEL_ORDER_NORMAL_EXCHANGE) DirectExchange cancelOrderExchange) {
//
//        return BindingBuilder.bind(cancelOrderQueue).to(cancelOrderExchange).with(OrderMQConstants.CANCEL_ORDER_ROUTING_KEY);
//    }
//
//    /**
//     * 取消订单绑定私信路由key
//     *
//     * @param orderDeadQueue
//     * @param orderDeadQueue
//     * @return
//     */
//    @Bean
//    public Binding cancelOrderDeadBindingDExchange(@Qualifier(OrderMQConstants.CANCEL_ORDER_DEAD_QUEUE) Queue orderDeadQueue,
//                                                   @Qualifier(OrderMQConstants.CANCEL_ORDER_EXCHANGE) DirectExchange orderDeadExchange) {
//        return BindingBuilder.bind(orderDeadQueue).to(orderDeadExchange).with(OrderMQConstants.CANCEL_ORDER_DEAD_ROUTING_KEY);
//    }
//
//
//}
